package com.aw.guiguzi.module.setting

import android.widget.CompoundButton
import android.widget.Switch
import com.aw.baselib.base.AwBaseBindingActivity
import com.aw.guiguzi.R
import com.aw.guiguzi.databinding.ActivitySettingHintBinding
import com.aw.guiguzi.util.AppCacheUtil

class SettingHintActivity : AwBaseBindingActivity<ActivitySettingHintBinding?>() {
    override fun getViewBinding(): ActivitySettingHintBinding {
        return ActivitySettingHintBinding.inflate(layoutInflater)
    }

    override fun initView() {
        super.initView()
        setToolbar("提示设置", null)
    }

    override fun initData() {
        super.initData()
        binding?.switchResultNumCheck?.isChecked = AppCacheUtil.isResultNumCheckHint()
        binding?.switchLastNums?.isChecked = AppCacheUtil.isAutoFillHint()
        binding?.switchFunHelpHint?.isChecked = AppCacheUtil.isFunHelpHint()
    }

    override fun initListener() {
        super.initListener()
        binding?.switchResultNumCheck?.setOnCheckedChangeListener { buttonView: CompoundButton?, isChecked: Boolean ->
            if (isChecked) {
                AppCacheUtil.setResultNumCheckHint(true)
                showMsg("结果数字选取提示已启用")
            } else {
                AppCacheUtil.setResultNumCheckHint(false)
                showMsg("结果数字选取提示已禁用")
            }
        }
        binding?.switchLastNums?.setOnCheckedChangeListener { buttonView: CompoundButton?, isChecked: Boolean ->
            if (isChecked) {
                AppCacheUtil.setAutoFillHint(true)
                AppCacheUtil.setFunHelpHint(false)
                binding?.switchFunHelpHint?.isChecked = false
                showMsg("自动填充提示已启用")
            } else {
                AppCacheUtil.setAutoFillHint(false)
                showMsg("自动填充提示已禁用")
            }
        }
        binding?.switchFunHelpHint?.setOnCheckedChangeListener { buttonView: CompoundButton?, isChecked: Boolean ->
            if (isChecked) {
                AppCacheUtil.setFunHelpHint(true)
                AppCacheUtil.setAutoFillHint(false)
                binding?.switchLastNums?.isChecked = false
                showMsg("功能帮助提示已启用")
            } else {
                AppCacheUtil.setFunHelpHint(false)
                showMsg("功能帮助提示已禁用")
            }
        }
    }
}